package open.api.config.payconfig;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: PayConfig
 * Package: com.qs.config.payconfig
 * Description:
 *
 * @Author: @weixueshi
 * @Create: 2024/1/1 - 15:06
 * @Version: v1.0
 */
@Configuration
public class PayConfig implements InitializingBean {
    /**
     * 支付url请求地址
     */
    public static String URL;

    @Value("${pay.URL}")
    public String url;

    /**
     * 单笔订单查询url请求地址
     */
    public static String QUERY_URL;

    @Value("${pay.QUERY_URL}")
    public String query_url;

    /**
     * 商户id
     */
    public static String PID;

    @Value("${pay.PID}")
    public String pid;

    /**
     * 商户密钥
     */
    public static String SECRET;

    @Value("${pay.SECRET}")
    public String secret;

    /**
     * 支付宝支付方式
     */
    public static String TYPE_ALIPAY;

    @Value("${pay.TYPE_ALIPAY}")
    public String type_alipay;

    /**
     * 微信支付方式
     */
    public static String TYPE_WXPAY;

    @Value("${pay.TYPE_WXPAY}")
    public String type_wxpay;

    /**
     * 微信支付方式
     */
    public static final String TYPE_WECHAT = "wechat";

    /**
     * 异步通知地址
     */
    public static String NOTIFY_URL;

    @Value("${pay.NOTIFY_URL}")
    public String notify_url;

    /**
     * 跳转通知地址
     */
    public static String RETURN_URL;

    @Value("${pay.RETURN_URL}")
    public String return_url;

    /**
     * 签名字符串
     */
    public static String SIGN;

    @Value("${pay.SIGN}")
    public String sign;

    /**
     * 签名类型
     */
    public static String SIGN_TYPE;

    @Value("${pay.SIGN_TYPE}")
    public String sign_type;

    /**
     * 字符串编码
     */
    public static String INPUT_CHARSET;

    @Value("${pay.INPUT_CHARSET}")
    public String input_charset;

    /**
     * 订单类型：1:本地订单号,2:商户订单号
     */
    public static String TYPE;

    @Value("${pay.TYPE}")
    public String type;

    @Override
    public void afterPropertiesSet() throws Exception {
        PayConfig.URL = url;
        PayConfig.QUERY_URL = query_url;
        PayConfig.PID = pid;
        PayConfig.SECRET = secret;
        PayConfig.TYPE_ALIPAY = type_alipay;
        PayConfig.TYPE_WXPAY = type_wxpay;
        PayConfig.NOTIFY_URL = notify_url;
        PayConfig.RETURN_URL = return_url;
        PayConfig.SIGN = sign;
        PayConfig.SIGN_TYPE = sign_type;
        PayConfig.INPUT_CHARSET = input_charset;
        PayConfig.TYPE = type;
    }
}
